package com.ellricky.baselib.adapter.reserve;


import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.cardview.widget.CardView;

import com.andr.common.ui.adapter.BaseRecyclerAdapter;
import com.andr.common.ui.adapter.SmartViewHolder;
import com.andr.common.util.StrUtil;
import com.ellricky.baselib.R;
import com.ellricky.baselib.entity.reserve.ReserveEntity;

public class ReserveAdapter extends BaseRecyclerAdapter<ReserveEntity> {

    private Activity context;

    public ReserveAdapter(Activity context) {
        super(R.layout.base_adapter_common_list);
        this.context = context;
    }

    @Override
    protected void onBindViewHolder(SmartViewHolder vh, ReserveEntity p1, int i) {
        View itemView = vh.itemView;

        CardView rootView = itemView.findViewById(R.id.cvRoot);
        TextView tvtitle = itemView.findViewById(R.id.tvTitle);
        TextView tvKey = itemView.findViewById(R.id.tvKey);
        TextView tvValue = itemView.findViewById(R.id.tvValue);
        TextView tvDateKey = itemView.findViewById(R.id.tvDateKey);
        TextView tvDate = itemView.findViewById(R.id.tvDate);
        ImageView ivEnd = itemView.findViewById(R.id.ivEnd);

        // 申请状态 2= 未排课 4=已排课
        String appointStatus = p1.getAppointStatus();
        boolean selected = "4".equals(appointStatus);

        rootView.setSelected(selected);
        tvtitle.setSelected(selected);
        tvKey.setSelected(selected);
        tvValue.setSelected(selected);
        tvDateKey.setSelected(selected);
        tvDate.setSelected(selected);

        if (selected) ivEnd.setImageResource(R.drawable.base_icon_common_list_white);
        else ivEnd.setImageResource(R.drawable.base_icon_common_list);

        tvtitle.setText(
                StrUtil.filterEmpty(p1.getName() + " " + p1.getSexName())
        );

        tvKey.setText(R.string.base_contact);
        tvValue.setText(p1.getTel());

        tvDateKey.setText(R.string.base_order_time);
        tvDate.setText(
                StrUtil.filterEmpty(p1.getAppointMarketDate() /*+ " " + p1.getExperienceDate()*/)
        );
    }
}